package Thread;

public class ThreadDemo7 {
    public static void main(String[] args) {
        Thread thread=new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("hello boy");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.start();
        System.out.println("join之前");  //等待线程
        try {
            thread.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < 3; i++) {
            System.out.println("hello main");
        }
        System.out.println("join之后");
    }
}
